home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Resources / Developers / XAMPP 1.5.4 / Windows installer / xampp-win32-1.5.4-installer.exe / xampp / php / install.txt < prev    next >
Encoding:
Text File  |  2006-08-23  |  88.6 KB  |  2,076 lines

  1. Installing PHP
  2.      _________________________________________________________________
  3.  
  4.    Table of Contents
  5.    Preface
  6.    1. General Installation Considerations
  7.    2. Installation on Windows systems
  8.  
  9.         Windows Installer
  10.         Manual Installation Steps
  11.         ActiveScript
  12.         Microsoft IIS / PWS
  13.         Apache 1.3.x on Microsoft Windows
  14.         Apache 2.0.x on Microsoft Windows
  15.         Sun, iPlanet and Netscape servers on Microsoft Windows
  16.         OmniHTTPd Server
  17.         Sambar Server on Microsoft Windows
  18.         Xitami on Microsoft Windows
  19.         Installation of extensions on Windows
  20.  
  21.    3. Installation of PECL extensions
  22.  
  23.         Introduction to PECL Installations
  24.         Downloading PECL extensions
  25.         PECL for Windows users
  26.         Compiling shared PECL extensions with PEAR
  27.         Compiling shared PECL extensions with phpize
  28.         Compiling PECL extensions statically into PHP
  29.  
  30.    4. Problems?
  31.  
  32.         Read the FAQ
  33.         Other problems
  34.         Bug reports
  35.  
  36.    5. Runtime Configuration
  37.  
  38.         The configuration file
  39.         How to change configuration settings
  40.  
  41.    6. Installation FAQ
  42.      _________________________________________________________________
  43.  
  44. Preface
  45.  
  46.    These installation instructions were generated from the HTML version
  47.    of the PHP Manual so formatting and linking have been altered. See the
  48.    online and updated version at: http://php.net/install.windows
  49.      _________________________________________________________________
  50.  
  51. Chapter 1. General Installation Considerations
  52.  
  53.    Before starting the installation, first you need to know what do you
  54.    want to use PHP for. There are three main fields you can use PHP, as
  55.    described in the What can PHP do? section:
  56.  
  57.      * Server-side scripting
  58.      * Command line scripting
  59.      * Client-side GUI applications
  60.  
  61.    For the first and most common form, you need three things: PHP itself,
  62.    a web server and a web browser. You probably already have a web
  63.    browser, and depending on your operating system setup, you may also
  64.    have a web server (e.g. Apache on Linux and MacOS X; IIS on Windows).
  65.    You may also rent webspace at a company. This way, you don't need to
  66.    set up anything on your own, only write your PHP scripts, upload it to
  67.    the server you rent, and see the results in your browser.
  68.  
  69.    While setting up the server and PHP on your own, you have two choices
  70.    for the method of connecting PHP to the server. For many servers PHP
  71.    has a direct module interface (also called SAPI). These servers
  72.    include Apache, Microsoft Internet Information Server, Netscape and
  73.    iPlanet servers. Many other servers have support for ISAPI, the
  74.    Microsoft module interface (OmniHTTPd for example). If PHP has no
  75.    module support for your web server, you can always use it as a CGI or
  76.    FastCGI processor. This means you set up your server to use the CGI
  77.    executable of PHP to process all PHP file requests on the server.
  78.  
  79.    If you are also interested to use PHP for command line scripting (e.g.
  80.    write scripts autogenerating some images for you offline, or
  81.    processing text files depending on some arguments you pass to them),
  82.    you always need the command line executable. For more information,
  83.    read the section about writing command line PHP applications. In this
  84.    case, you need no server and no browser.
  85.  
  86.    With PHP you can also write desktop GUI applications using the PHP-GTK
  87.    extension. This is a completely different approach than writing web
  88.    pages, as you do not output any HTML, but manage windows and objects
  89.    within them. For more information about PHP-GTK, please visit the site
  90.    dedicated to this extension. PHP-GTK is not included in the official
  91.    PHP distribution.
  92.  
  93.    From now on, this section deals with setting up PHP for web servers on
  94.    Unix and Windows with server module interfaces and CGI executables.
  95.    You will also find information on the command line executable in the
  96.    following sections.
  97.  
  98.    PHP source code and binary distributions for Windows can be found at
  99.    http://www.php.net/downloads.php. We recommend you to choose a mirror
  100.    nearest to you for downloading the distributions.
  101.      _________________________________________________________________
  102.  
  103. Chapter 2. Installation on Windows systems
  104.  
  105.    This section applies to Windows 98/Me and Windows NT/2000/XP/2003. PHP
  106.    will not work on 16 bit platforms such as Windows 3.1 and sometimes we
  107.    refer to the supported Windows platforms as Win32. Windows 95 is no
  108.    longer supported as of PHP 4.3.0.
  109.  
  110.    There are two main ways to install PHP for Windows: either manually or
  111.    by using the installer.
  112.  
  113.    If you have Microsoft Visual Studio, you can also build PHP from the
  114.    original source code.
  115.  
  116.    Once you have PHP installed on your Windows system, you may also want
  117.    to load various extensions for added functionality.
  118.  
  119.    Warning
  120.  
  121.    There are several all-in-one installers over the Internet, but none of
  122.    those are endorsed by PHP.net, as we believe that the manual
  123.    installation is the best choice to have your system secure and
  124.    optimised.
  125.      _________________________________________________________________
  126.  
  127. Windows Installer
  128.  
  129.    The Windows PHP installer is available from the downloads page at
  130.    http://www.php.net/downloads.php. This installs the CGI version of PHP
  131.    and for IIS, PWS, and Xitami, it configures the web server as well.
  132.    The installer does not include any extra external PHP extensions
  133.    (php_*.dll) as you'll only find those in the Windows Zip Package and
  134.    PECL downloads.
  135.  
  136.      Note: While the Windows installer is an easy way to make PHP work,
  137.      it is restricted in many aspects as, for example, the automatic
  138.      setup of extensions is not supported. Use of the installer isn't
  139.      the preferred method for installing PHP.
  140.  
  141.    First, install your selected HTTP (web) server on your system, and
  142.    make sure that it works.
  143.  
  144.    Run the executable installer and follow the instructions provided by
  145.    the installation wizard. Two types of installation are supported -
  146.    standard, which provides sensible defaults for all the settings it
  147.    can, and advanced, which asks questions as it goes along.
  148.  
  149.    The installation wizard gathers enough information to set up the
  150.    php.ini file, and configure certain web servers to use PHP. One of the
  151.    web servers the PHP installer does not configure for is Apache, so
  152.    you'll need to configure it manually.
  153.  
  154.    Once the installation has completed, the installer will inform you if
  155.    you need to restart your system, restart the server, or just start
  156.    using PHP.
  157.  
  158.    Warning
  159.  
  160.    Be aware, that this setup of PHP is not secure. If you would like to
  161.    have a secure PHP setup, you'd better go on the manual way, and set
  162.    every option carefully. This automatically working setup gives you an
  163.    instantly working PHP installation, but it is not meant to be used on
  164.    online servers.
  165.      _________________________________________________________________
  166.  
  167. Manual Installation Steps
  168.  
  169.    This install guide will help you manually install and configure PHP
  170.    with a web server on Microsoft Windows. To get started you'll need to
  171.    download the zip binary distribution from the downloads page at
  172.    http://www.php.net/downloads.php.
  173.  
  174.    Although there are many all-in-one installation kits, and we also
  175.    distribute a PHP installer for Microsoft Windows, we recommend you
  176.    take the time to setup PHP yourself as this will provide you with a
  177.    better understanding of the system, and enables you to install PHP
  178.    extensions easily when needed.
  179.  
  180.      Upgrading from a previous PHP version: Previous editions of the
  181.      manual suggest moving various ini and DLL files into your SYSTEM
  182.      (i.e. C:\WINDOWS) folder and while this simplifies the installation
  183.      procedure it makes upgrading difficult. We advise you remove all of
  184.      these files (like php.ini and PHP related DLLs from the Windows
  185.      SYSTEM folder) before moving on with a new PHP installation. Be
  186.      sure to backup these files as you might break the entire system.
  187.      The old php.ini might be useful in setting up the new PHP as well.
  188.      And as you'll soon learn, the preferred method for installing PHP
  189.      is to keep all PHP related files in one directory and have this
  190.      directory available to your systems PATH.
  191.  
  192.      MDAC requirements: If you use Microsoft Windows 98/NT4 download the
  193.      latest version of the Microsoft Data Access Components (MDAC) for
  194.      your platform. MDAC is available at
  195.      http://msdn.microsoft.com/data/. This requirement exists because
  196.      ODBC is built into the distributed Windows binaries.
  197.  
  198.    The following steps should be completed on all installations before
  199.    any server specific instructions are performed:
  200.  
  201.    Extract the distribution file into a directory of your choice. If you
  202.    are installing PHP 4, extract to C:\, as the zip file expands to a
  203.    foldername like php-4.3.7-Win32. If you are installing PHP 5, extract
  204.    to C:\php as the zip file doesn't expand as in PHP 4. You may choose a
  205.    different location but do not have spaces in the path (like C:\Program
  206.    Files\PHP) as some web servers will crash if you do.
  207.  
  208.    The directory structure extracted from the zip is different for PHP
  209.    versions 4 and 5 and look like as follows:
  210.  
  211.    Example 2-1. PHP 4 package structure
  212. c:\php
  213.    |
  214.    +--cli
  215.    |  |
  216.    |  |-php.exe           -- CLI executable - ONLY for commandline scripting
  217.    |
  218.    +--dlls                -- support DLLs required by some extensions
  219.    |  |
  220.    |  |-expat.dll
  221.    |  |
  222.    |  |-fdftk.dll
  223.    |  |
  224.    |  |-...
  225.    |
  226.    +--extensions          -- extension DLLs for PHP
  227.    |  |
  228.    |  |-php_bz2.dll
  229.    |  |
  230.    |  |-php_cpdf.dll
  231.    |  |
  232.    |  |-..
  233.    |
  234.    +--mibs                -- support files for SNMP
  235.    |
  236.    +--openssl             -- support files for Openssl
  237.    |
  238.    +--pdf-related         -- support files for PDF
  239.    |
  240.    +--sapi                -- SAPI (server module support) DLLs
  241.    |  |
  242.    |  |-php4apache.dll
  243.    |  |
  244.    |  |-php4apache2.dll
  245.    |  |
  246.    |  |-..
  247.    |
  248.    +--PEAR                -- initial copy of PEAR
  249.    |
  250.    |
  251.    |-go-pear.bat          -- PEAR setup script
  252.    |
  253.    |-..
  254.    |
  255.    |-php.exe              -- CGI executable
  256.    |
  257.    |-..
  258.    |
  259.    |-php.ini-dist         -- default php.ini settings
  260.    |
  261.    |-php.ini-recommended  -- recommended php.ini settings
  262.    |
  263.    |-php4ts.dll           -- core PHP DLL
  264.    |
  265.    |-...
  266.  
  267.    Or:
  268.  
  269.    Example 2-2. PHP 5 package structure
  270. c:\php
  271.    |
  272.    +--dev
  273.    |  |
  274.    |  |-php5ts.lib
  275.    |
  276.    +--ext                 -- extension DLLs for PHP
  277.    |  |
  278.    |  |-php_bz2.dll
  279.    |  |
  280.    |  |-php_cpdf.dll
  281.    |  |
  282.    |  |-..
  283.    |
  284.    +--extras
  285.    |  |
  286.    |  +--mibs             -- support files for SNMP
  287.    |  |
  288.    |  +--openssl          -- support files for Openssl
  289.    |  |
  290.    |  +--pdf-related      -- support files for PDF
  291.    |  |
  292.    |  |-mime.magic
  293.    |
  294.    +--pear                -- initial copy of PEAR
  295.    |
  296.    |
  297.    |-go-pear.bat          -- PEAR setup script
  298.    |
  299.    |-fdftk.dll
  300.    |
  301.    |-..
  302.    |
  303.    |-php-cgi.exe          -- CGI executable
  304.    |
  305.    |-php-win.exe          -- executes scripts without an opened command prompt
  306.    |
  307.    |-php.exe              -- CLI executable - ONLY for command line scripting
  308.    |
  309.    |-..
  310.    |
  311.    |-php.ini-dist         -- default php.ini settings
  312.    |
  313.    |-php.ini-recommended  -- recommended php.ini settings
  314.    |
  315.    |-php5activescript.dll
  316.    |
  317.    |-php5apache.dll
  318.    |
  319.    |-php5apache2.dll
  320.    |
  321.    |-..
  322.    |
  323.    |-php5ts.dll           -- core PHP DLL
  324.    |
  325.    |-...
  326.  
  327.    Notice the differences and similarities. Both PHP 4 and PHP 5 have a
  328.    CGI executable, a CLI executable, and server modules, but they are
  329.    located in different folders and/or have different names. While PHP 4
  330.    packages have the server modules in the sapi folder, PHP 5
  331.    distributions have no such directory and instead they're in the PHP
  332.    folder root. The supporting DLLs for the PHP 5 extensions are also not
  333.    in a seperate directory.
  334.  
  335.      Note: In PHP 4, you should move all files located in the dll and
  336.      sapi folders to the main folder (e.g. C:\php).
  337.  
  338.    Here is a list of server modules shipped with PHP 4 and PHP 5:
  339.  
  340.      * sapi/php4activescript.dll (php5activescript.dll) - ActiveScript
  341.        engine, allowing you to embed PHP in your Windows applications.
  342.      * sapi/php4apache.dll (php5apache.dll) - Apache 1.3.x module.
  343.      * sapi/php4apache2.dll (php5apache2.dll) - Apache 2.0.x module.
  344.      * sapi/php4isapi.dll (php5isapi.dll) - ISAPI Module for ISAPI
  345.        compliant web servers like IIS 4.0/PWS 4.0 or newer.
  346.      * sapi/php4nsapi.dll (php5nsapi.dll) - Sun/iPlanet/Netscape server
  347.        module.
  348.      * sapi/php4pi3web.dll (no equivalent in PHP 5) - Pi3Web server
  349.        module.
  350.  
  351.    Server modules provide significantly better performance and additional
  352.    functionality compared to the CGI binary. The CLI version is designed
  353.    to let you use PHP for command line scripting. More information about
  354.    CLI is available in the chapter about using PHP from the command line.
  355.  
  356.    Warning
  357.  
  358.    The SAPI modules have been significantly improved as of the 4.1
  359.    release, however, in older systems you may encounter server errors or
  360.    other server modules failing, such as ASP.
  361.  
  362.    The CGI and CLI binaries, and the web server modules all require the
  363.    php4ts.dll (php5ts.dll) file to be available to them. You have to make
  364.    sure that this file can be found by your PHP installation. The search
  365.    order for this DLL is as follows:
  366.  
  367.      * The same directory from where php.exe is called, or in case you
  368.        use a SAPI module, the web server's directory (e.g. C:\Program
  369.        Files\Apache Group\Apache2\bin).
  370.      * Any directory in your Windows PATH environment variable.
  371.  
  372.    To make php4ts.dll / php5ts.dll available you have three options: copy
  373.    the file to the Windows system directory, copy the file to the web
  374.    server's directory, or add your PHP directory, C:\php to the PATH. For
  375.    better maintenance, we advise you to follow the last option, add
  376.    C:\php to the PATH, because it will be simpler to upgrade PHP in the
  377.    future. Read more about how to add your PHP directory to PATH in the
  378.    corresponding FAQ entry (and then don't forget to restart the computer
  379.    - logoff isn't enough).
  380.  
  381.    The next step is to set up a valid configuration file for PHP,
  382.    php.ini. There are two ini files distributed in the zip file,
  383.    php.ini-dist and php.ini-recommended. We advise you to use
  384.    php.ini-recommended, because we optimized the default settings in this
  385.    file for performance, and security. Read this well documented file
  386.    carefully because it has changes from php.ini-dist that will
  387.    drastically affect your setup. Some examples are display_errors being
  388.    off and magic_quotes_gpc being off. In addition to reading these,
  389.    study the ini settings and set every element manually yourself. If you
  390.    would like to achieve the best security, then this is the way for you,
  391.    although PHP works fine with these default ini files. Copy your chosen
  392.    ini-file to a directory that PHP is able to find and rename it to
  393.    php.ini. PHP searches for php.ini in the locations described in the
  394.    Section called The configuration file in Chapter 5 section.
  395.  
  396.    If you are running Apache 2, the simpler option is to use the
  397.    PHPIniDir directive (read the installation on Apache 2 page),
  398.    otherwise your best option is to set the PHPRC environment variable.
  399.    This process is explained in the following FAQ entry.
  400.  
  401.      Note: If you're using NTFS on Windows NT, 2000, XP or 2003, make
  402.      sure that the user running the web server has read permissions to
  403.      your php.ini (e.g. make it readable by Everyone).
  404.  
  405.    The following steps are optional:
  406.  
  407.      * Edit your new php.ini file. If you plan to use OmniHTTPd, do not
  408.        follow the next step. Set the doc_root to point to your web
  409.        servers document_root. For example:
  410.  
  411. doc_root = c:\inetpub\wwwroot // for IIS/PWS
  412.  
  413. doc_root = c:\apache\htdocs // for Apache
  414.  
  415.      * Choose the extensions you would like to load when PHP starts. See
  416.        the section about Windows extensions, about how to set up one, and
  417.        what is already built in. Note that on a new installation it is
  418.        advisable to first get PHP working and tested without any
  419.        extensions before enabling them in php.ini.
  420.      * On PWS and IIS, you can set the browscap configuration setting to
  421.        point to: c:\windows\system\inetsrv\browscap.ini on Windows 9x/Me,
  422.        c:\winnt\system32\inetsrv\browscap.ini on NT/2000, and
  423.        c:\windows\system32\inetsrv\browscap.ini on XP. For an up-to-date
  424.        browscap.ini, read the following FAQ.
  425.  
  426.    PHP is now setup on your system. The next step is to choose a web
  427.    server, and enable it to run PHP. Choose a webserver from the table of
  428.    contents.
  429.      _________________________________________________________________
  430.  
  431. ActiveScript
  432.  
  433.    This section contains notes specific to the ActiveScript installation.
  434.  
  435.    ActiveScript is a windows only SAPI that enables you to use PHP script
  436.    in any ActiveScript compliant host, like Windows Script Host,
  437.    ASP/ASP.NET, Windows Script Components or Microsoft Scriptlet control.
  438.  
  439.    As of PHP 5.0.1, ActiveScript has been moved to the PECL repository.
  440.    You may download this PECL extension DLL from the PHP Downloads page
  441.    or at http://snaps.php.net/.
  442.  
  443.      Note: You should read the manual installation steps first!
  444.  
  445.    After installing PHP, you should download the ActiveScript DLL
  446.    (php5activescript.dll) and place it in the main PHP folder (e.g.
  447.    C:\php).
  448.  
  449.    After having all the files needed, you must register the DLL on your
  450.    system. To achieve this, open a Command Prompt window (located in the
  451.    Start Menu). Then go to your PHP directory by typing something like cd
  452.    C:\php. To register the DLL just type regsvr32 php5activescript.dll.
  453.  
  454.    To test if ActiveScript is working, create a new file, named test.wsf
  455.    (the extension is very important) and type:
  456. <job id="test">
  457.  
  458.  <script language="PHPScript">
  459.   $WScript->Echo("Hello World!");
  460.  </script>
  461.  
  462. </job>
  463.  
  464.    Save and double-click on the file. If you receive a little window
  465.    saying "Hello World!" you're done.
  466.  
  467.      Note: In PHP 4, the engine was named 'ActivePHP', so if you are
  468.      using PHP 4, you should replace 'PHPScript' with 'ActivePHP' in the
  469.      above example.
  470.  
  471.      Note: ActiveScript doesn't use the default php.ini file. Instead,
  472.      it will look only in the same directory as the .exe that caused it
  473.      to load. You should create php-activescript.ini and place it in
  474.      that folder, if you wish to load extensions, etc.
  475.      _________________________________________________________________
  476.  
  477. Microsoft IIS / PWS
  478.  
  479.    This section contains notes and hints specific to IIS (Microsoft
  480.    Internet Information Server).
  481.  
  482.    Warning
  483.  
  484.    By using the CGI setup, your server is open to several possible
  485.    attacks. Please read our CGI security section to learn how to defend
  486.    yourself from those attacks.
  487.      _________________________________________________________________
  488.  
  489. General considerations for all installations of PHP with IIS
  490.  
  491.      * First, read the Manual Installation Instructions. Do not skip this
  492.        step as it provides crucial information for installing PHP on
  493.        Windows.
  494.      * CGI users must set the cgi.force_redirect PHP directive to 0
  495.        inside php.ini. Read the faq on cgi.force_redirect for important
  496.        details. Also, CGI users may want to set the
  497.        cgi.redirect_status_env directive. When using directives, be sure
  498.        these directives aren't commented out inside php.ini.
  499.      * The PHP 4 CGI is named php.exe while in PHP 5 it's php-cgi.exe. In
  500.        PHP 5, php.exe is the CLI, and not the CGI.
  501.      * Modify the Windows PATH environment variable to include the PHP
  502.        directory. This way the PHP DLL files, PHP executables, and
  503.        php.ini can all remain in the PHP directory without cluttering up
  504.        the Windows system directory. For more details, see the FAQ on
  505.        Setting the PATH.
  506.      * The IIS user (usually IUSR_MACHINENAME) needs permission to read
  507.        various files and directories, such as php.ini, docroot, and the
  508.        session tmp directory.
  509.      * Be sure the extension_dir and doc_root PHP directives are
  510.        appropriately set in php.ini. These directives depend on the
  511.        system that PHP is being installed on. In PHP 4, the extension_dir
  512.        is extensions while with PHP 5 it's ext. So, an example PHP 5
  513.        extensions_dir value is "c:\php\ext" and an example IIS doc_root
  514.        value is "c:\Inetpub\wwwroot".
  515.      * PHP extension DLL files, such as php_mysql.dll and php_curl.dll,
  516.        are found in the zip package of the PHP download (not the PHP
  517.        installer). In PHP 5, many extensions are part of PECL and can be
  518.        downloaded in the "Collection of PECL modules" package. Files such
  519.        as php_zip.dll and php_ssh2.dll. Download PHP files here.
  520.      * When defining the executable, the 'check that file exists' box may
  521.        also be checked. For a small performance penalty, the IIS (or PWS)
  522.        will check that the script file exists and sort out authentication
  523.        before firing up PHP. This means that the web server will provide
  524.        sensible 404 style error messages instead of CGI errors
  525.        complaining that PHP did not output any data.
  526.      _________________________________________________________________
  527.  
  528. Windows NT/200x/XP and IIS 4 or newer
  529.  
  530.    PHP may be installed as a CGI binary, or with the ISAPI module. In
  531.    either case, you need to start the Microsoft Management Console (may
  532.    appear as 'Internet Services Manager', either in your Windows NT 4.0
  533.    Option Pack branch or the Control Panel=>Administrative Tools under
  534.    Windows 2000/XP). Then right click on your Web server node (this will
  535.    most probably appear as 'Default Web Server'), and select
  536.    'Properties'.
  537.  
  538.    If you want to use the CGI binary, do the following:
  539.  
  540.      * Under 'Home Directory', 'Virtual Directory', or 'Directory', do
  541.        the following:
  542.      * Change the Execute Permissions to 'Scripts only'
  543.      * Click on the 'Configuration' button, and choose the Application
  544.        Mappings tab. Click Add and set the Executable path to the
  545.        appropriate CGI file. An example PHP 5 value is:
  546.        C:\php\php-cgi.exe Supply .php as the extension. Leave 'Method
  547.        exclusions' blank, and check the 'Script engine' checkbox. Now,
  548.        click OK a few times.
  549.      * Set up the appropriate security. (This is done in Internet Service
  550.        Manager), and if your NT Server uses NTFS file system, add execute
  551.        rights for I_USR_ to the directory that contains php.exe /
  552.        php-cgi.exe.
  553.  
  554.    To use the ISAPI module, do the following:
  555.  
  556.      * If you don't want to perform HTTP Authentication using PHP, you
  557.        can (and should) skip this step. Under ISAPI Filters, add a new
  558.        ISAPI filter. Use PHP as the filter name, and supply a path to the
  559.        php4isapi.dll / php5isapi.dll.
  560.      * Under 'Home Directory', 'Virtual Directory', or 'Directory', do
  561.        the following:
  562.      * Change the Execute Permissions to 'Scripts only'
  563.      * Click on the 'Configuration' button, and choose the Application
  564.        Mappings tab. Click Add and set the Executable path to the
  565.        appropriate ISAPI DLL. An example PHP 5 value is:
  566.        C:\php\php5isapi.dll Supply .php as the extension. Leave 'Method
  567.        exclusions' blank, and check the 'Script engine' checkbox. Now,
  568.        click OK a few times.
  569.      * Stop IIS completely (NET STOP iisadmin)
  570.      * Start IIS again (NET START w3svc)
  571.  
  572.    With IIS 6 (2003 Server), open up the IIS Manager, go to Web Service
  573.    Extensions, choose "Add a new Web service extension", enter in a name
  574.    such as PHP, choose the Add button and for the value browse to either
  575.    the ISAPI file (php4isapi.dll or php5isapi.dll) or CGI (php.exe or
  576.    php-cgi.exe) then check "Set extension status to Allowed" and click
  577.    OK.
  578.  
  579.    In order to use index.php as a default content page, do the following:
  580.    From within the Documents tab, choose Add. Type in index.php and click
  581.    OK. Adjust the order by choosing Move Up or Move Down. This is similar
  582.    to setting DirectoryIndex with Apache.
  583.  
  584.    The steps above must be repeated for each extension that is to be
  585.    associated with PHP scripts. .php is the most common although .php3
  586.    may be required for legacy applications.
  587.  
  588.    If you experience 100% CPU usage after some time, turn off the IIS
  589.    setting Cache ISAPI Application.
  590.      _________________________________________________________________
  591.  
  592. Windows and PWS 4
  593.  
  594.    PWS 4 does not support ISAPI, only PHP CGI should be used.
  595.  
  596.      * Edit the enclosed pws-php4cgi.reg / pws-php5cgi.reg file (look
  597.        into the SAPI folder for PHP 4, or in the main folder for PHP 5)
  598.        to reflect the location of your php.exe / php-cgi.exe. Backslashes
  599.        should be escaped, for example:
  600.        [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\w3svc\parame
  601.        ters\Script Map] ".php"="C:\\php\\php.exe" (change to
  602.        C:\\php\\php-cgi.exe if you are using PHP 5) Now merge this
  603.        registery file into your system; you may do this by
  604.        double-clicking it.
  605.      * In the PWS Manager, right click on a given directory you want to
  606.        add PHP support to, and select Properties. Check the 'Execute'
  607.        checkbox, and confirm.
  608.      _________________________________________________________________
  609.  
  610. Windows and PWS/IIS 3
  611.  
  612.    The recommended method for configuring these servers is to use the REG
  613.    file included with the distribution (pws-php4cgi.reg in the SAPI
  614.    folder for PHP 4, or pws-php5cgi.reg in the main folder for PHP 5).
  615.    You may want to edit this file and make sure the extensions and PHP
  616.    install directories match your configuration. Or you can follow the
  617.    steps below to do it manually.
  618.  
  619.    Warning
  620.  
  621.    These steps involve working directly with the Windows registry. One
  622.    error here can leave your system in an unstable state. We highly
  623.    recommend that you back up your registry first. The PHP Development
  624.    team will not be held responsible if you damage your registry.
  625.  
  626.      * Run Regedit.
  627.      * Navigate to: HKEY_LOCAL_MACHINE /System /CurrentControlSet
  628.        /Services /W3Svc /Parameters /ScriptMap.
  629.      * On the edit menu select: New->String Value.
  630.      * Type in the extension you wish to use for your php scripts. For
  631.        example .php
  632.      * Double click on the new string value and enter the path to php.exe
  633.        in the value data field. ex: C:\php\php.exe "%s" %s for PHP 4, or
  634.        C:\php\php-cgi.exe "%s" %s for PHP 5.
  635.      * Repeat these steps for each extension you wish to associate with
  636.        PHP scripts.
  637.  
  638.    The following steps do not affect the web server installation and only
  639.    apply if you want your PHP scripts to be executed when they are run
  640.    from the command line (ex. run C:\myscripts\test.php) or by double
  641.    clicking on them in a directory viewer window. You may wish to skip
  642.    these steps as you might prefer the PHP files to load into a text
  643.    editor when you double click on them.
  644.  
  645.      * Navigate to: HKEY_CLASSES_ROOT
  646.      * On the edit menu select: New->Key.
  647.      * Name the key to the extension you setup in the previous section.
  648.        ex: .php
  649.      * Highlight the new key and in the right side pane, double click the
  650.        "default value" and enter phpfile.
  651.      * Repeat the last step for each extension you set up in the previous
  652.        section.
  653.      * Now create another New->Key under HKEY_CLASSES_ROOT and name it
  654.        phpfile.
  655.      * Highlight the new key phpfile and in the right side pane, double
  656.        click the "default value" and enter PHP Script.
  657.      * Right click on the phpfile key and select New->Key, name it Shell.
  658.      * Right click on the Shell key and select New->Key, name it open.
  659.      * Right click on the open key and select New->Key, name it command.
  660.      * Highlight the new key command and in the right side pane, double
  661.        click the "default value" and enter the path to php.exe. ex:
  662.        c:\php\php.exe -q %1. (don't forget the %1).
  663.      * Exit Regedit.
  664.      * If using PWS on Windows, reboot to reload the registry.
  665.  
  666.    PWS and IIS 3 users now have a fully operational system. IIS 3 users
  667.    can use a nifty tool from Steven Genusa to configure their script
  668.    maps.
  669.      _________________________________________________________________
  670.  
  671. Apache 1.3.x on Microsoft Windows
  672.  
  673.    This section contains notes and hints specific to Apache 1.3.x
  674.    installs of PHP on Microsoft Windows systems. There are also
  675.    instructions and notes for Apache 2 on a separate page.
  676.  
  677.      Note: Please read the manual installation steps first!
  678.  
  679.    There are two ways to set up PHP to work with Apache 1.3.x on Windows.
  680.    One is to use the CGI binary (php.exe for PHP 4 and php-cgi.exe for
  681.    PHP 5), the other is to use the Apache Module DLL. In either case you
  682.    need to edit your httpd.conf to configure Apache to work with PHP, and
  683.    then restart the server.
  684.  
  685.    It is worth noting here that now the SAPI module has been made more
  686.    stable under Windows, we recommend it's use above the CGI binary,
  687.    since it is more transparent and secure.
  688.  
  689.    Although there can be a few variations of configuring PHP under
  690.    Apache, these are simple enough to be used by the newcomer. Please
  691.    consult the Apache Documentation for further configuration directives.
  692.  
  693.    After changing the configuration file, remember to restart the server,
  694.    for example, NET STOP APACHE followed by NET START APACHE, if you run
  695.    Apache as a Windows Service, or use your regular shortcuts.
  696.  
  697.      Note: Remember that when adding path values in the Apache
  698.      configuration files on Windows, all backslashes such as
  699.      c:\directory\file.ext must be converted to forward slashes, as
  700.      c:/directory/file.ext.
  701.      _________________________________________________________________
  702.  
  703. Installing as an Apache module
  704.  
  705.    You should add the following lines to your Apache httpd.conf file:
  706.  
  707.    Example 2-3. PHP as an Apache 1.3.x module
  708.  
  709.    This assumes PHP is installed to c:\php. Adjust the path if this is
  710.    not the case.
  711.  
  712.    For PHP 4:
  713. # Add to the end of the LoadModule section
  714. # Don't forget to copy this file from the sapi directory!
  715. LoadModule php4_module "C:/php/php4apache.dll"
  716.  
  717. # Add to the end of the AddModule section
  718. AddModule mod_php4.c
  719.  
  720.    For PHP 5:
  721. # Add to the end of the LoadModule section
  722. LoadModule php5_module "C:/php/php5apache.dll"
  723.  
  724. # Add to the end of the AddModule section
  725. AddModule mod_php5.c
  726.  
  727.    For both:
  728. # Add this line inside the <IfModule mod_mime.c> conditional brace
  729. AddType application/x-httpd-php .php
  730.  
  731. # For syntax highlighted .phps files, also add
  732. AddType application/x-httpd-php-source .phps
  733.      _________________________________________________________________
  734.  
  735. Installing as a CGI binary
  736.  
  737.    If you unzipped the PHP package to C:\php\ as described in the Manual
  738.    Installation Steps section, you need to insert these lines to your
  739.    Apache configuration file to set up the CGI binary:
  740.  
  741.    Example 2-4. PHP and Apache 1.3.x as CGI
  742. ScriptAlias /php/ "c:/php/"
  743. AddType application/x-httpd-php .php
  744.  
  745. # For PHP 4
  746. Action application/x-httpd-php "/php/php.exe"
  747.  
  748. # For PHP 5
  749. Action application/x-httpd-php "/php/php-cgi.exe"
  750.  
  751. # specify the directory where php.ini is
  752. SetEnv PHPRC C:/php
  753.  
  754.    Note that the second line in the list above can be found in the actual
  755.    versions of httpd.conf, but it is commented out. Remember also to
  756.    substitute the c:/php/ for your actual path to PHP.
  757.  
  758.    Warning
  759.  
  760.    By using the CGI setup, your server is open to several possible
  761.    attacks. Please read our CGI security section to learn how to defend
  762.    yourself from those attacks.
  763.  
  764.    If you would like to present PHP source files syntax highlighted,
  765.    there is no such convenient option as with the module version of PHP.
  766.    If you chose to configure Apache to use PHP as a CGI binary, you will
  767.    need to use the highlight_file() function. To do this simply create a
  768.    PHP script file and add this code: <?php
  769.    highlight_file('some_php_script.php'); ?>.
  770.      _________________________________________________________________
  771.  
  772. Apache 2.0.x on Microsoft Windows
  773.  
  774.    This section contains notes and hints specific to Apache 2.0.x
  775.    installs of PHP on Microsoft Windows systems. We also have
  776.    instructions and notes for Apache 1.3.x users on a separate page.
  777.  
  778.      Note: You should read the manual installation steps first!
  779.  
  780.    Warning
  781.  
  782.    We do not recommend using a threaded MPM in production with Apache2.
  783.    Use the prefork MPM instead, or use Apache1. For information on why,
  784.    read the related FAQ entry on using Apache2 with a threaded MPM
  785.  
  786.    You are highly encouraged to take a look at the Apache Documentation
  787.    to get a basic understanding of the Apache 2.0.x Server. Also consider
  788.    to read the Windows specific notes for Apache 2.0.x before reading on
  789.    here.
  790.  
  791.      PHP and Apache 2.0.x compatibility notes: The following versions of
  792.      PHP are known to work with the most recent version of Apache 2.0.x:
  793.  
  794.      * PHP 4.3.0 or later available at http://www.php.net/downloads.php.
  795.      * the latest stable development version. Get the source code
  796.        http://snaps.php.net/php5-latest.tar.gz or download binaries for
  797.        Windows http://snaps.php.net/win32/php5-win32-latest.zip.
  798.      * a prerelease version downloadable from http://qa.php.net/.
  799.      * you have always the option to obtain PHP through anonymous CVS.
  800.  
  801.      These versions of PHP are compatible to Apache 2.0.40 and later.
  802.  
  803.      Apache 2.0 SAPI-support started with PHP 4.2.0. PHP 4.2.3 works
  804.      with Apache 2.0.39, don't use any other version of Apache with PHP
  805.      4.2.3. However, the recommended setup is to use PHP 4.3.0 or later
  806.      with the most recent version of Apache2.
  807.  
  808.      All mentioned versions of PHP will work still with Apache 1.3.x.
  809.  
  810.    Warning
  811.  
  812.    Apache 2.0.x is designed to run on Windows NT 4.0, Windows 2000 or
  813.    Windows XP. At this time, support for Windows 9x is incomplete. Apache
  814.    2.0.x is not expected to work on those platforms at this time.
  815.  
  816.    Download the most recent version of Apache 2.0.x and a fitting PHP
  817.    version. Follow the Manual Installation Steps and come back to go on
  818.    with the integration of PHP and Apache.
  819.  
  820.    There are two ways to set up PHP to work with Apache 2.0.x on Windows.
  821.    One is to use the CGI binary the other is to use the Apache module
  822.    DLL. In either case you need to edit your httpd.conf to configure
  823.    Apache to work with PHP and then restart the server.
  824.  
  825.      Note: Remember that when adding path values in the Apache
  826.      configuration files on Windows, all backslashes such as
  827.      c:\directory\file.ext must be converted to forward slashes, as
  828.      c:/directory/file.ext.
  829.      _________________________________________________________________
  830.  
  831. Installing as a CGI binary
  832.  
  833.    You need to insert these three lines to your Apache httpd.conf
  834.    configuration file to set up the CGI binary:
  835.  
  836.    Example 2-5. PHP and Apache 2.0 as CGI
  837. ScriptAlias /php/ "c:/php/"
  838. AddType application/x-httpd-php .php
  839.  
  840. # For PHP 4
  841. Action application/x-httpd-php "/php/php.exe"
  842.  
  843. # For PHP 5
  844. Action application/x-httpd-php "/php/php-cgi.exe"
  845.  
  846.    Warning
  847.  
  848.    By using the CGI setup, your server is open to several possible
  849.    attacks. Please read our CGI security section to learn how to defend
  850.    yourself from those attacks.
  851.      _________________________________________________________________
  852.  
  853. Installing as an Apache module
  854.  
  855.    You need to insert these two lines to your Apache httpd.conf
  856.    configuration file to set up the PHP module for Apache 2.0:
  857.  
  858.    Example 2-6. PHP and Apache 2.0 as Module
  859. # For PHP 4 do something like this:
  860. LoadModule php4_module "c:/php/php4apache2.dll"
  861. # Don't forget to copy the php4apache2.dll file from the sapi directory!
  862. AddType application/x-httpd-php .php
  863.  
  864. # For PHP 5 do something like this:
  865. LoadModule php5_module "c:/php/php5apache2.dll"
  866. AddType application/x-httpd-php .php
  867.  
  868. # configure the path to php.ini
  869. PHPIniDir "C:/php"
  870.  
  871.      Note: Remember to substitute your actual path to PHP for the
  872.      c:/php/ in the above examples. Take care to use either
  873.      php4apache2.dll or php5apache2.dll in your LoadModule directive and
  874.      not php4apache.dll or php5apache.dll as the latter ones are
  875.      designed to run with Apache 1.3.x.
  876.  
  877.      Note: If you want to use content negotiation, read related FAQ.
  878.  
  879.    Warning
  880.  
  881.    Don't mix up your installation with DLL files from different PHP
  882.    versions. You have the only choice to use the DLL's and extensions
  883.    that ship with your downloaded PHP version.
  884.      _________________________________________________________________
  885.  
  886. Sun, iPlanet and Netscape servers on Microsoft Windows
  887.  
  888.    This section contains notes and hints specific to Sun Java System Web
  889.    Server, Sun ONE Web Server, iPlanet and Netscape server installs of
  890.    PHP on Windows.
  891.  
  892.    From PHP 4.3.3 on you can use PHP scripts with the NSAPI module to
  893.    generate custom directory listings and error pages. Additional
  894.    functions for Apache compatibility are also available. For support in
  895.    current webservers read the note about subrequests.
  896.      _________________________________________________________________
  897.  
  898. CGI setup on Sun, iPlanet and Netscape servers
  899.  
  900.    To install PHP as a CGI handler, do the following:
  901.  
  902.      * Copy php4ts.dll to your systemroot (the directory where you
  903.        installed Windows)
  904.      * Make a file association from the command line. Type the following
  905.        two lines:
  906.  
  907. assoc .php=PHPScript
  908. ftype PHPScript=c:\php\php.exe %1 %*
  909.  
  910.      * In the Netscape Enterprise Administration Server create a dummy
  911.        shellcgi directory and remove it just after (this step creates 5
  912.        important lines in obj.conf and allow the web server to handle
  913.        shellcgi scripts).
  914.      * In the Netscape Enterprise Administration Server create a new mime
  915.        type (Category: type, Content-Type: magnus-internal/shellcgi, File
  916.        Suffix:php).
  917.      * Do it for each web server instance you want PHP to run
  918.  
  919.    More details about setting up PHP as a CGI executable can be found
  920.    here: http://benoit.noss.free.fr/php/install-php.html
  921.      _________________________________________________________________
  922.  
  923. NSAPI setup on Sun, iPlanet and Netscape servers
  924.  
  925.    To install PHP with NSAPI, do the following:
  926.  
  927.      * Copy php4ts.dll to your systemroot (the directory where you
  928.        installed Windows)
  929.      * Make a file association from the command line. Type the following
  930.        two lines:
  931.  
  932. assoc .php=PHPScript
  933. ftype PHPScript=c:\php\php.exe %1 %*
  934.  
  935.      * In the Netscape Enterprise Administration Server create a new mime
  936.        type (Category: type, Content-Type: magnus-internal/x-httpd-php,
  937.        File Suffix: php).
  938.      * Edit magnus.conf (for servers >= 6) or obj.conf (for servers < 6)
  939.        and add the following: You should place the lines after mime types
  940.        init.
  941.  
  942. Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="c:
  943. /php/sapi/php4nsapi.dll"
  944. Init fn="php4_init" LateInit="yes" errorString="Failed to initialise PHP!" [php
  945. _ini="c:/path/to/php.ini"]
  946.  
  947.        (PHP >= 4.3.3) The php_ini parameter is optional but with it you
  948.        can place your php.ini in your webserver config directory.
  949.      * Configure the default object in obj.conf (for virtual server
  950.        classes [Sun Web Server 6.0+] in their vserver.obj.conf): In the
  951.        <Object name="default"> section, place this line necessarily after
  952.        all 'ObjectType' and before all 'AddLog' lines:
  953.  
  954. Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value inik
  955. ey=value ...]
  956.  
  957.        (PHP >= 4.3.3) As additional parameters you can add some special
  958.        php.ini-values, for example you can set a
  959.        docroot="/path/to/docroot" specific to the context php4_execute is
  960.        called. For boolean ini-keys please use 0/1 as value, not
  961.        "On","Off",... (this will not work correctly), e.g.
  962.        zlib.output_compression=1 instead of zlib.output_compression="On"
  963.      * This is only needed if you want to configure a directory that only
  964.        consists of PHP scripts (same like a cgi-bin directory):
  965.  
  966. <Object name="x-httpd-php">
  967. ObjectType fn="force-type" type="magnus-internal/x-httpd-php"
  968. Service fn=php4_execute [inikey=value inikey=value ...]
  969. </Object>
  970.  
  971.        After that you can configure a directory in the Administration
  972.        server and assign it the style x-httpd-php. All files in it will
  973.        get executed as PHP. This is nice to hide PHP usage by renaming
  974.        files to .html.
  975.      * Restart your web service and apply changes
  976.      * Do it for each web server instance you want PHP to run
  977.  
  978.      Note: More details about setting up PHP as an NSAPI filter can be
  979.      found here: http://benoit.noss.free.fr/php/install-php4.html
  980.  
  981.      Note: The stacksize that PHP uses depends on the configuration of
  982.      the webserver. If you get crashes with very large PHP scripts, it
  983.      is recommended to raise it with the Admin Server (in the section
  984.      "MAGNUS EDITOR").
  985.      _________________________________________________________________
  986.  
  987. CGI environment and recommended modifications in php.ini
  988.  
  989.    Important when writing PHP scripts is the fact that Sun JSWS/Sun ONE
  990.    WS/iPlanet/Netscape is a multithreaded web server. Because of that all
  991.    requests are running in the same process space (the space of the
  992.    webserver itself) and this space has only one environment. If you want
  993.    to get CGI variables like PATH_INFO, HTTP_HOST etc. it is not the
  994.    correct way to try this in the old PHP 3.x way with getenv() or a
  995.    similar way (register globals to environment, $_ENV). You would only
  996.    get the environment of the running webserver without any valid CGI
  997.    variables!
  998.  
  999.      Note: Why are there (invalid) CGI variables in the environment?
  1000.  
  1001.      Answer: This is because you started the webserver process from the
  1002.      admin server which runs the startup script of the webserver, you
  1003.      wanted to start, as a CGI script (a CGI script inside of the admin
  1004.      server!). This is why the environment of the started webserver has
  1005.      some CGI environment variables in it. You can test this by starting
  1006.      the webserver not from the administration server. Use the command
  1007.      line as root user and start it manually - you will see there are no
  1008.      CGI-like environment variables.
  1009.  
  1010.    Simply change your scripts to get CGI variables in the correct way for
  1011.    PHP 4.x by using the superglobal $_SERVER. If you have older scripts
  1012.    which use $HTTP_HOST, etc., you should turn on register_globals in
  1013.    php.ini and change the variable order too (important: remove "E" from
  1014.    it, because you do not need the environment here):
  1015. variables_order = "GPCS"
  1016. register_globals = On
  1017.      _________________________________________________________________
  1018.  
  1019. Special use for error pages or self-made directory listings (PHP >= 4.3.3)
  1020.  
  1021.    You can use PHP to generate the error pages for "404 Not Found" or
  1022.    similar. Add the following line to the object in obj.conf for every
  1023.    error page you want to overwrite:
  1024. Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value ini
  1025. key=value...]
  1026.  
  1027.    where XXX is the HTTP error code. Please delete any other Error
  1028.    directives which could interfere with yours. If you want to place a
  1029.    page for all errors that could exist, leave the code parameter out.
  1030.    Your script can get the HTTP status code with $_SERVER['ERROR_TYPE'].
  1031.  
  1032.    Another possibility is to generate self-made directory listings. Just
  1033.    create a PHP script which displays a directory listing and replace the
  1034.    corresponding default Service line for
  1035.    type="magnus-internal/directory" in obj.conf with the following:
  1036. Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/scr
  1037. ipt.php" [inikey=value inikey=value...]
  1038.  
  1039.    For both error and directory listing pages the original URI and
  1040.    translated URI are in the variables $_SERVER['PATH_INFO'] and
  1041.    $_SERVER['PATH_TRANSLATED'].
  1042.      _________________________________________________________________
  1043.  
  1044. Note about nsapi_virtual() and subrequests (PHP >= 4.3.3)
  1045.  
  1046.    The NSAPI module now supports the nsapi_virtual() function (alias:
  1047.    virtual()) to make subrequests on the webserver and insert the result
  1048.    in the webpage. The problem is, that this function uses some
  1049.    undocumented features from the NSAPI library.
  1050.  
  1051.    Under Unix this is not a problem, because the module automatically
  1052.    looks for the needed functions and uses them if available. If not,
  1053.    nsapi_virtual() is disabled.
  1054.  
  1055.    Under Windows limitations in the DLL handling need the use of a
  1056.    automatic detection of the most recent ns-httpdXX.dll file. This is
  1057.    tested for servers till version 6.1. If a newer version of the Sun
  1058.    server is used, the detection fails and nsapi_virtual() is disabled.
  1059.  
  1060.    If this is the case, try the following: Add the following parameter to
  1061.    php4_init in magnus.conf/obj.conf:
  1062.    Init fn=php4_init ... server_lib="ns-httpdXX.dll"
  1063.  
  1064.    where XX is the correct DLL version number. To get it, look in the
  1065.    server-root for the correct DLL name. The DLL with the biggest
  1066.    filesize is the right one.
  1067.  
  1068.    You can check the status by using the phpinfo() function.
  1069.  
  1070.      Note: But be warned: Support for nsapi_virtual() is EXPERIMENTAL!!!
  1071.      _________________________________________________________________
  1072.  
  1073. OmniHTTPd Server
  1074.  
  1075.    This section contains notes and hints specific to OmniHTTPd on
  1076.    Windows.
  1077.  
  1078.      Note: You should read the manual installation steps first!
  1079.  
  1080.    Warning
  1081.  
  1082.    By using the CGI setup, your server is open to several possible
  1083.    attacks. Please read our CGI security section to learn how to defend
  1084.    yourself from those attacks.
  1085.  
  1086.    You need to complete the following steps to make PHP work with
  1087.    OmniHTTPd. This is a CGI executable setup. SAPI is supported by
  1088.    OmniHTTPd, but some tests have shown that it is not so stable to use
  1089.    PHP as an ISAPI module.
  1090.  
  1091.      Important for CGI users: Read the faq on cgi.force_redirect for
  1092.      important details. This directive needs to be set to 0.
  1093.  
  1094.     1. Install OmniHTTPd server.
  1095.     2. Right click on the blue OmniHTTPd icon in the system tray and
  1096.        select Properties
  1097.     3. Click on Web Server Global Settings
  1098.     4. On the 'External' tab, enter: virtual = .php | actual =
  1099.        c:\php\php.exe (use php-cgi.exe if installing PHP 5), and use the
  1100.        Add button.
  1101.     5. On the Mime tab, enter: virtual = wwwserver/stdcgi | actual =
  1102.        .php, and use the Add button.
  1103.     6. Click OK
  1104.  
  1105.    Repeat steps 2 - 6 for each extension you want to associate with PHP.
  1106.  
  1107.      Note: Some OmniHTTPd packages come with built in PHP support. You
  1108.      can choose at setup time to do a custom setup, and uncheck the PHP
  1109.      component. We recommend you to use the latest PHP binaries. Some
  1110.      OmniHTTPd servers come with PHP 4 beta distributions, so you should
  1111.      choose not to set up the built in support, but install your own. If
  1112.      the server is already on your machine, use the Replace button in
  1113.      Step 4 and 5 to set the new, correct information.
  1114.      _________________________________________________________________
  1115.  
  1116. Sambar Server on Microsoft Windows
  1117.  
  1118.    This section contains notes and hints specific to the Sambar Server
  1119.    for Windows.
  1120.  
  1121.      Note: You should read the manual installation steps first!
  1122.  
  1123.    This list describes how to set up the ISAPI module to work with the
  1124.    Sambar server on Windows.
  1125.  
  1126.      * Find the file called mappings.ini (in the config directory) in the
  1127.        Sambar install directory.
  1128.      * Open mappings.ini and add the following line under [ISAPI]:
  1129.  
  1130.    Example 2-7. ISAPI configuration of Sambar
  1131. #for PHP 4
  1132. *.php = c:\php\php4isapi.dll
  1133.  
  1134. #for PHP 5
  1135. *.php = c:\php\php5isapi.dll
  1136.  
  1137.        (This line assumes that PHP was installed in c:\php.)
  1138.      * Now restart the Sambar server for the changes to take effect.
  1139.      _________________________________________________________________
  1140.  
  1141. Xitami on Microsoft Windows
  1142.  
  1143.    This section contains notes and hints specific to Xitami on Windows.
  1144.  
  1145.      Note: You should read the manual installation steps first!
  1146.  
  1147.    This list describes how to set up the PHP CGI binary to work with
  1148.    Xitami on Windows.
  1149.  
  1150.      Important for CGI users: Read the faq on cgi.force_redirect for
  1151.      important details. This directive needs to be set to 0. If you want
  1152.      to use $_SERVER['PHP_SELF'] you have to enable the cgi.fix_pathinfo
  1153.      directive.
  1154.  
  1155.    Warning
  1156.  
  1157.    By using the CGI setup, your server is open to several possible
  1158.    attacks. Please read our CGI security section to learn how to defend
  1159.    yourself from those attacks.
  1160.  
  1161.      * Make sure the webserver is running, and point your browser to
  1162.        xitamis admin console (usually http://127.0.0.1/admin), and click
  1163.        on Configuration.
  1164.      * Navigate to the Filters, and put the extension which PHP should
  1165.        parse (i.e. .php) into the field File extensions (.xxx).
  1166.      * In Filter command or script put the path and name of your PHP CGI
  1167.        executable i.e. C:\php\php.exe for PHP 4, or C:\php\php-cgi.exe
  1168.        for PHP 5.
  1169.      * Press the 'Save' icon.
  1170.      * Restart the server to reflect changes.
  1171.      _________________________________________________________________
  1172.  
  1173. Installation of extensions on Windows
  1174.  
  1175.    After installing PHP and a webserver on Windows, you will probably
  1176.    want to install some extensions for added functionality. You can
  1177.    choose which extensions you would like to load when PHP starts by
  1178.    modifying your php.ini. You can also load a module dynamically in your
  1179.    script using dl().
  1180.  
  1181.    The DLLs for PHP extensions are prefixed with php_.
  1182.  
  1183.    Many extensions are built into the Windows version of PHP. This means
  1184.    additional DLL files, and the extension directive, are not used to
  1185.    load these extensions. The Windows PHP Extensions table lists
  1186.    extensions that require, or used to require, additional PHP DLL files.
  1187.    Here's a list of built in extensions:
  1188.  
  1189.    In PHP 4 (updated PHP 4.3.11): BCMath, Caledar, COM, Ctype, FTP,
  1190.    MySQL, ODBC, Overload, PCRE, Session, Tokenizer, WDDX, XML and Zlib
  1191.  
  1192.    In PHP 5 (updated PHP 5.0.4), the following changes exist. Built in:
  1193.    DOM, LibXML, Iconv, SimpleXML, SPL and SQLite. And the following are
  1194.    no longer built in: MySQL and Overload.
  1195.  
  1196.    The default location PHP searches for extensions is C:\php4\extensions
  1197.    in PHP 4 and C:\php5 in PHP 5. To change this setting to reflect your
  1198.    setup of PHP edit your php.ini file:
  1199.  
  1200.      * You will need to change the extension_dir setting to point to the
  1201.        directory where your extensions lives, or where you have placed
  1202.        your php_*.dll files. For example:
  1203.  
  1204. extension_dir = C:\php\extensions
  1205.  
  1206.      * Enable the extension(s) in php.ini you want to use by uncommenting
  1207.        the extension=php_*.dll lines in php.ini. This is done by deleting
  1208.        the leading ; from the extension you want to load.
  1209.  
  1210.    Example 2-8. Enable Bzip2 extension for PHP-Windows
  1211. // change the following line from ...
  1212. ;extension=php_bz2.dll
  1213.  
  1214. // ... to
  1215. extension=php_bz2.dll
  1216.  
  1217.      * Some of the extensions need extra DLLs to work. Couple of them can
  1218.        be found in the distribution package, in the C:\php\dlls\ folder
  1219.        in PHP 4 or in the main folder in PHP 5, but some, for example
  1220.        Oracle (php_oci8.dll) require DLLs which are not bundled with the
  1221.        distribution package. If you are installing PHP 4, copy the
  1222.        bundled DLLs from C:\php\dlls folder to the main C:\php folder.
  1223.        Don't forget to include C:\php in the system PATH (this process is
  1224.        explained in a separate FAQ entry).
  1225.      * Some of these DLLs are not bundled with the PHP distribution. See
  1226.        each extensions documentation page for details. Also, read the
  1227.        manual section titled Installation of PECL extensions for details
  1228.        on PECL. An increasingly large number of PHP extensions are found
  1229.        in PECL, and these extensions require a separate download.
  1230.  
  1231.      Note: If you are running a server module version of PHP remember to
  1232.      restart your webserver to reflect your changes to php.ini.
  1233.  
  1234.    The following table describes some of the extensions available and
  1235.    required additional dlls.
  1236.  
  1237.    Table 2-1. PHP Extensions
  1238.    Extension Description Notes
  1239.    php_bz2.dll bzip2 compression functions None
  1240.    php_calendar.dll Calendar conversion functions Built in since PHP
  1241.    4.0.3
  1242.    php_cpdf.dll ClibPDF functions None
  1243.    php_crack.dll Crack functions None
  1244.    php_ctype.dll ctype family functions Built in since PHP 4.3.0
  1245.    php_curl.dll CURL, Client URL library functions Requires:
  1246.    libeay32.dll, ssleay32.dll (bundled)
  1247.    php_cybercash.dll Cybercash payment functions PHP <= 4.2.0
  1248.    php_db.dll DBM functions Deprecated. Use DBA instead (php_dba.dll)
  1249.    php_dba.dll DBA: DataBase (dbm-style) Abstraction layer functions None
  1250.    php_dbase.dll dBase functions None
  1251.    php_dbx.dll dbx functions
  1252.    php_domxml.dll DOM XML functions PHP <= 4.2.0 requires: libxml2.dll
  1253.    (bundled) PHP >= 4.3.0 requires: iconv.dll (bundled)
  1254.    php_dotnet.dll .NET functions PHP <= 4.1.1
  1255.    php_exif.dll EXIF functions php_mbstring.dll. And, php_exif.dll must
  1256.    be loaded after php_mbstring.dll in php.ini.
  1257.    php_fbsql.dll FrontBase functions PHP <= 4.2.0
  1258.    php_fdf.dll FDF: Forms Data Format functions. Requires: fdftk.dll
  1259.    (bundled)
  1260.    php_filepro.dll filePro functions Read-only access
  1261.    php_ftp.dll FTP functions Built-in since PHP 4.0.3
  1262.    php_gd.dll GD library image functions Removed in PHP 4.3.2. Also note
  1263.    that truecolor functions are not available in GD1, instead, use
  1264.    php_gd2.dll.
  1265.    php_gd2.dll GD library image functions GD2
  1266.    php_gettext.dll Gettext functions PHP <= 4.2.0 requires
  1267.    gnu_gettext.dll (bundled), PHP >= 4.2.3 requires libintl-1.dll,
  1268.    iconv.dll (bundled).
  1269.    php_hyperwave.dll HyperWave functions None
  1270.    php_iconv.dll ICONV characterset conversion Requires: iconv-1.3.dll
  1271.    (bundled), PHP >=4.2.1 iconv.dll
  1272.    php_ifx.dll Informix functions Requires: Informix libraries
  1273.    php_iisfunc.dll IIS management functions None
  1274.    php_imap.dll IMAP POP3 and NNTP functions None
  1275.    php_ingres.dll Ingres II functions Requires: Ingres II libraries
  1276.    php_interbase.dll InterBase functions Requires: gds32.dll (bundled)
  1277.    php_java.dll Java functions PHP <= 4.0.6 requires: jvm.dll (bundled)
  1278.    php_ldap.dll LDAP functions PHP <= 4.2.0 requires libsasl.dll
  1279.    (bundled), PHP >= 4.3.0 requires libeay32.dll, ssleay32.dll (bundled)
  1280.    php_mbstring.dll Multi-Byte String functions None
  1281.    php_mcrypt.dll Mcrypt Encryption functions Requires: libmcrypt.dll
  1282.    php_mhash.dll Mhash functions PHP >= 4.3.0 requires: libmhash.dll
  1283.    (bundled)
  1284.    php_mime_magic.dll Mimetype functions Requires: magic.mime (bundled)
  1285.    php_ming.dll Ming functions for Flash None
  1286.    php_msql.dll mSQL functions Requires: msql.dll (bundled)
  1287.    php_mssql.dll MSSQL functions Requires: ntwdblib.dll (bundled)
  1288.    php_mysql.dll MySQL functions PHP >= 5.0.0, requires libmysql.dll
  1289.    (bundled)
  1290.    php_mysqli.dll MySQLi functions PHP >= 5.0.0, requires libmysql.dll
  1291.    (libmysqli.dll in PHP <= 5.0.2) (bundled)
  1292.    php_oci8.dll Oracle 8 functions Requires: Oracle 8.1+ client libraries
  1293.    php_openssl.dll OpenSSL functions Requires: libeay32.dll (bundled)
  1294.    php_oracle.dll Oracle functions Requires: Oracle 7 client libraries
  1295.    php_overload.dll Object overloading functions Built in since PHP 4.3.0
  1296.    php_pdf.dll PDF functions None
  1297.    php_pgsql.dll PostgreSQL functions None
  1298.    php_printer.dll Printer functions None
  1299.    php_shmop.dll Shared Memory functions None
  1300.    php_snmp.dll SNMP get and walk functions NT only!
  1301.    php_soap.dll SOAP functions PHP >= 5.0.0
  1302.    php_sockets.dll Socket functions None
  1303.    php_sybase_ct.dll Sybase functions Requires: Sybase client libraries
  1304.    php_tidy.dll Tidy functions PHP >= 5.0.0
  1305.    php_tokenizer.dll Tokenizer functions Built in since PHP 4.3.0
  1306.    php_w32api.dll W32api functions None
  1307.    php_xmlrpc.dll XML-RPC functions PHP >= 4.2.1 requires: iconv.dll
  1308.    (bundled)
  1309.    php_xslt.dll XSLT functions PHP <= 4.2.0 requires sablot.dll,
  1310.    expat.dll (bundled). PHP >= 4.2.1 requires sablot.dll, expat.dll,
  1311.    iconv.dll (bundled).
  1312.    php_yaz.dll YAZ functions Requires: yaz.dll (bundled)
  1313.    php_zip.dll Zip File functions Read only access
  1314.    php_zlib.dll ZLib compression functions Built in since PHP 4.3.0
  1315.      _________________________________________________________________
  1316.  
  1317. Chapter 3. Installation of PECL extensions
  1318.  
  1319. Introduction to PECL Installations
  1320.  
  1321.    PECL is a repository of PHP extensions that are made available to you
  1322.    via the PEAR packaging system. This section of the manual is intended
  1323.    to demonstrate how to obtain and install PECL extensions.
  1324.  
  1325.    These instructions assume /your/phpsrcdir/ is the path to the PHP
  1326.    source distribution, and that extname is the name of the PECL
  1327.    extension. Adjust accordingly. These instructions also assume a
  1328.    familiarity with the pear command.
  1329.  
  1330.    To be useful, a shared extension must be built, installed, and loaded.
  1331.    The methods described below provide you with various instructions on
  1332.    how to build and install the extensions, but they do not automatically
  1333.    load them. Extensions can be loaded by adding an extension directive.
  1334.    To this php.ini file, or through the use of the dl() function.
  1335.  
  1336.    When building PHP modules, it's important to have known-good versions
  1337.    of the required tools (autoconf, automake, libtool, etc.) See the
  1338.    Anonymous CVS Instructions for details on the required tools, and
  1339.    required versions.
  1340.      _________________________________________________________________
  1341.  
  1342. Downloading PECL extensions
  1343.  
  1344.    There are several options for downloading PECL extensions, such as:
  1345.  
  1346.      * http://pecl.php.net
  1347.        The PECL web site contains information about the different
  1348.        extensions that are offered by the PHP Development Team. The
  1349.        information available here includes: ChangeLog, release notes,
  1350.        requirements and other similar details.
  1351.      * pear download extname
  1352.        PECL extensions that have releases listed on the PECL web site are
  1353.        available for download and installation using the pear command.
  1354.        Specific revisions may also be specified.
  1355.      * CVS
  1356.        Most PECL extensions also reside in CVS. A web-based view may be
  1357.        seen at http://cvs.php.net/pecl/. To download straight from CVS,
  1358.        the following sequence of commands may be used. Note that phpfi is
  1359.        the password for user cvsread:
  1360.  
  1361. $ cvs -d:pserver:cvsread@cvs.php.net:/repository login
  1362. $ cvs -d:pserver:cvsread@cvs.php.net:/repository co pecl/extname
  1363.  
  1364.      * Windows downloads
  1365.        Windows users may find compiled PECL binaries by downloading the
  1366.        Collection of PECL modules from the PHP Downloads page, and by
  1367.        retrieving a PECL Snapshot. To compile PHP under Windows, read the
  1368.        Win32 Build README.
  1369.      _________________________________________________________________
  1370.  
  1371. PECL for Windows users
  1372.  
  1373.    As with any other PHP extension DLL, installation is as simple as
  1374.    copying the PECL extension DLLs into the extension_dir folder and
  1375.    loading them from php.ini. For example, add the following line to your
  1376.    php.ini:
  1377.  
  1378.    extension=php_extname.dll
  1379.  
  1380.    After doing this, restart the web server.
  1381.      _________________________________________________________________
  1382.  
  1383. Compiling shared PECL extensions with PEAR
  1384.  
  1385.    PEAR makes it easy to create shared PHP extensions. Using the pear
  1386.    command, do the following:
  1387.  
  1388.    $ pear install extname
  1389.  
  1390.    This will download the source for extname, compile, and install
  1391.    extname.so into your extension_dir. extname.so may then be loaded via
  1392.    php.ini
  1393.  
  1394.    By default, the pear command will not install packages that are marked
  1395.    with the alpha or beta state. If no stable packages are available, you
  1396.    may install a beta package using the following command:
  1397.  
  1398.    $ pear install extname-beta
  1399.  
  1400.    You may also install a specific version using this variant:
  1401.  
  1402.    $ pear install extname-0.1
  1403.      _________________________________________________________________
  1404.  
  1405. Compiling shared PECL extensions with phpize
  1406.  
  1407.    Sometimes, using the pear installer is not an option. This could be
  1408.    because you're behind a firewall, or it could be because the extension
  1409.    you want to install is not available as a PEAR compatible package,
  1410.    such as unreleased extensions from CVS. If you need to build such an
  1411.    extension, you can use the lower-level build tools to perform the
  1412.    build manually.
  1413.  
  1414.    The phpize command is used to prepare the build environment for a PHP
  1415.    extension. In the following sample, the sources for an extension are
  1416.    in a directory named extname:
  1417.  
  1418. $ cd extname
  1419. $ phpize
  1420. $ ./configure
  1421. $ make
  1422. # make install
  1423.  
  1424.    A successful install will have created extname.so and put it into the
  1425.    PHP extensions directory. You'll need to and adjust php.ini and add an
  1426.    extension=extname.so line before you can use the extension.
  1427.      _________________________________________________________________
  1428.  
  1429. Compiling PECL extensions statically into PHP
  1430.  
  1431.    You might find that you need to build a PECL extension statically into
  1432.    your PHP binary. To do this, you'll need to place the extension source
  1433.    under the php-src/ext/ directory and tell the PHP build system to
  1434.    regenerate its configure script.
  1435.  
  1436. $ cd /your/phpsrcdir/ext
  1437. $ pear download extname
  1438. $ gzip -d < extname.tgz | tar -xvf -
  1439. $ mv extname-x.x.x extname
  1440.  
  1441.    This will result in the following directory:
  1442.  
  1443.    /your/phpsrcdir/ext/extname
  1444.  
  1445.    From here, force PHP to rebuild the configure script, and then build
  1446.    PHP as normal:
  1447.  
  1448. $ cd /your/phpsrcdir
  1449. $ rm configure
  1450. $ ./buildconf --force
  1451. $ ./configure --help
  1452. $ ./configure --with-extname --enable-someotherext --with-foobar
  1453. $ make
  1454. $ make install
  1455.  
  1456.      Note: To run the 'buildconf' script you need autoconf 2.13 and
  1457.      automake 1.4+ (newer versions of autoconf may work, but are not
  1458.      supported).
  1459.  
  1460.    Whether --enable-extname or --with-extname is used depends on the
  1461.    extension. Typically an extension that does not require external
  1462.    libraries uses --enable. To be sure, run the following after
  1463.    buildconf:
  1464.  
  1465.    $ ./configure --help | grep extname
  1466.      _________________________________________________________________
  1467.  
  1468. Chapter 4. Problems?
  1469.  
  1470. Read the FAQ
  1471.  
  1472.    Some problems are more common than others. The most common ones are
  1473.    listed in the PHP FAQ, part of this manual.
  1474.      _________________________________________________________________
  1475.  
  1476. Other problems
  1477.  
  1478.    If you are still stuck, someone on the PHP installation mailing list
  1479.    may be able to help you. You should check out the archive first, in
  1480.    case someone already answered someone else who had the same problem as
  1481.    you. The archives are available from the support page on
  1482.    http://www.php.net/support.php. To subscribe to the PHP installation
  1483.    mailing list, send an empty mail to
  1484.    php-install-subscribe@lists.php.net. The mailing list address is
  1485.    php-install@lists.php.net.
  1486.  
  1487.    If you want to get help on the mailing list, please try to be precise
  1488.    and give the necessary details about your environment (which operating
  1489.    system, what PHP version, what web server, if you are running PHP as
  1490.    CGI or a server module, safe mode, etc...), and preferably enough code
  1491.    to make others able to reproduce and test your problem.
  1492.      _________________________________________________________________
  1493.  
  1494. Bug reports
  1495.  
  1496.    If you think you have found a bug in PHP, please report it. The PHP
  1497.    developers probably don't know about it, and unless you report it,
  1498.    chances are it won't be fixed. You can report bugs using the
  1499.    bug-tracking system at http://bugs.php.net/. Please do not send bug
  1500.    reports in mailing list or personal letters. The bug system is also
  1501.    suitable to submit feature requests.
  1502.  
  1503.    Read the How to report a bug document before submitting any bug
  1504.    reports!
  1505.      _________________________________________________________________
  1506.  
  1507. Chapter 5. Runtime Configuration
  1508.  
  1509. The configuration file
  1510.  
  1511.    The configuration file (called php3.ini in PHP 3, and simply php.ini
  1512.    as of PHP 4) is read when PHP starts up. For the server module
  1513.    versions of PHP, this happens only once when the web server is
  1514.    started. For the CGI and CLI version, it happens on every invocation.
  1515.  
  1516.    php.ini is searched in these locations (in order):
  1517.  
  1518.      * SAPI module specific location (PHPIniDir directive in Apache 2, -c
  1519.        command line option in CGI and CLI, php_ini parameter in NSAPI,
  1520.        PHP_INI_PATH environment variable in THTTPD)
  1521.      * HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath (Windows Registry
  1522.        location)
  1523.      * The PHPRC environment variable
  1524.      * Current working directory (for CLI)
  1525.      * The web server's directory (for SAPI modules), or directory of PHP
  1526.        (otherwise in Windows)
  1527.      * Windows directory (C:\windows or C:\winnt) (for Windows), or
  1528.        --with-config-file-path compile time option
  1529.  
  1530.    If php-SAPI.ini exists (where SAPI is used SAPI, so the filename is
  1531.    e.g. php-cli.ini or php-apache.ini), it's used instead of php.ini.
  1532.    SAPI name can be determined by php_sapi_name().
  1533.  
  1534.      Note: The Apache web server changes the directory to root at
  1535.      startup causing PHP to attempt to read php.ini from the root
  1536.      filesystem if it exists.
  1537.  
  1538.    The php.ini directives handled by extensions are documented
  1539.    respectively on the pages of the extensions themselves. The list of
  1540.    the core directives is available in the appendix. Probably not all PHP
  1541.    directives are documented in the manual though. For a complete list of
  1542.    directives available in your PHP version, please read your well
  1543.    commented php.ini file. Alternatively, you may find the the latest
  1544.    php.ini from CVS helpful too.
  1545.  
  1546.    Example 5-1. php.ini example
  1547. ; any text on a line after an unquoted semicolon (;) is ignored
  1548. [php] ; section markers (text within square brackets) are also ignored
  1549. ; Boolean values can be set to either:
  1550. ;    true, on, yes
  1551. ; or false, off, no, none
  1552. register_globals = off
  1553. track_errors = yes
  1554.  
  1555. ; you can enclose strings in double-quotes
  1556. include_path = ".:/usr/local/lib/php"
  1557.  
  1558. ; backslashes are treated the same as any other character
  1559. include_path = ".;c:\php\lib"
  1560.  
  1561.    Since PHP 5.1.0, it is possible to refer to existing .ini variables
  1562.    from within .ini files. Example: open_basedir = ${open_basedir}
  1563.    ":/new/dir".
  1564.      _________________________________________________________________
  1565.  
  1566. How to change configuration settings
  1567.  
  1568. Running PHP as an Apache module
  1569.  
  1570.    When using PHP as an Apache module, you can also change the
  1571.    configuration settings using directives in Apache configuration files
  1572.    (e.g. httpd.conf) and .htaccess files. You will need "AllowOverride
  1573.    Options" or "AllowOverride All" privileges to do so.
  1574.  
  1575.    With PHP 4 and PHP 5, there are several Apache directives that allow
  1576.    you to change the PHP configuration from within the Apache
  1577.    configuration files. For a listing of which directives are
  1578.    PHP_INI_ALL, PHP_INI_PERDIR, or PHP_INI_SYSTEM, have a look at the
  1579.    List of php.ini directives appendix.
  1580.  
  1581.      Note: With PHP 3, there are Apache directives that correspond to
  1582.      each configuration setting in the php3.ini name, except the name is
  1583.      prefixed by "php3_".
  1584.  
  1585.    php_value name value
  1586.           Sets the value of the specified directive. Can be used only
  1587.           with PHP_INI_ALL and PHP_INI_PERDIR type directives. To clear a
  1588.           previously set value use none as the value.
  1589.  
  1590.      Note: Don't use php_value to set boolean values. php_flag (see
  1591.      below) should be used instead.
  1592.  
  1593.    php_flag name on|off
  1594.           Used to set a boolean configuration directive. Can be used only
  1595.           with PHP_INI_ALL and PHP_INI_PERDIR type directives.
  1596.  
  1597.    php_admin_value name value
  1598.           Sets the value of the specified directive. This can not be used
  1599.           in .htaccess files. Any directive type set with php_admin_value
  1600.           can not be overridden by .htaccess or virtualhost directives.
  1601.           To clear a previously set value use none as the value.
  1602.  
  1603.    php_admin_flag name on|off
  1604.           Used to set a boolean configuration directive. This can not be
  1605.           used in .htaccess files. Any directive type set with
  1606.           php_admin_flag can not be overridden by .htaccess or
  1607.           virtualhost directives.
  1608.  
  1609.    Example 5-2. Apache configuration example
  1610. <IfModule mod_php5.c>
  1611.   php_value include_path ".:/usr/local/lib/php"
  1612.   php_admin_flag safe_mode on
  1613. </IfModule>
  1614. <IfModule mod_php4.c>
  1615.   php_value include_path ".:/usr/local/lib/php"
  1616.   php_admin_flag safe_mode on
  1617. </IfModule>
  1618. <IfModule mod_php3.c>
  1619.   php3_include_path ".:/usr/local/lib/php"
  1620.   php3_safe_mode on
  1621. </IfModule>
  1622.  
  1623.    Caution
  1624.  
  1625.    PHP constants do not exist outside of PHP. For example, in httpd.conf
  1626.    you can not use PHP constants such as E_ALL or E_NOTICE to set the
  1627.    error_reporting directive as they will have no meaning and will
  1628.    evaluate to 0. Use the associated bitmask values instead. These
  1629.    constants can be used in php.ini
  1630.      _________________________________________________________________
  1631.  
  1632. Changing PHP configuration via the Windows registry
  1633.  
  1634.    When running PHP on Windows, the configuration values can be modified
  1635.    on a per-directory basis using the Windows registry. The configuration
  1636.    values are stored in the registry key HKLM\SOFTWARE\PHP\Per Directory
  1637.    Values, in the sub-keys corresponding to the path names. For example,
  1638.    configuration values for the directory c:\inetpub\wwwroot would be
  1639.    stored in the key HKLM\SOFTWARE\PHP\Per Directory
  1640.    Values\c\inetpub\wwwroot. The settings for the directory would be
  1641.    active for any script running from this directory or any subdirectory
  1642.    of it. The values under the key should have the name of the PHP
  1643.    configuration directive and the string value. PHP constants in the
  1644.    values are not parsed. However, only configuration values changeable
  1645.    in PHP_INI_USER can be set this way, PHP_INI_PERDIR values can not.
  1646.      _________________________________________________________________
  1647.  
  1648. Other interfaces to PHP
  1649.  
  1650.    Regardless of how you run PHP, you can change certain values at
  1651.    runtime of your scripts through ini_set(). See the documentation on
  1652.    the ini_set() page for more information.
  1653.  
  1654.    If you are interested in a complete list of configuration settings on
  1655.    your system with their current values, you can execute the phpinfo()
  1656.    function, and review the resulting page. You can also access the
  1657.    values of individual configuration directives at runtime using
  1658.    ini_get() or get_cfg_var().
  1659.      _________________________________________________________________
  1660.  
  1661. Chapter 6. Installation FAQ
  1662.  
  1663.    This section holds common questions about the way to install PHP. PHP
  1664.    is available for almost any OS (except maybe for MacOS before OSX),
  1665.    and almost any web server.
  1666.  
  1667.    To install PHP, follow the instructions in the INSTALL file located in
  1668.    the distribution. Windows users should also read the install.txt file.
  1669.    There are also some helpful hints for Windows users here.
  1670.  
  1671.    1. Why shouldn't I use Apache2 with a threaded MPM in a production
  1672.           environment?
  1673.  
  1674.    2. Unix/Windows: Where should my php.ini file be located?
  1675.    3. Unix: I installed PHP, but every time I load a document, I get the
  1676.           message 'Document Contains No Data'! What's going on here?
  1677.  
  1678.    4. Unix: I installed PHP using RPMS, but Apache isn't processing the
  1679.           PHP pages! What's going on here?
  1680.  
  1681.    5. Unix: I installed PHP 3 using RPMS, but it doesn't compile with the
  1682.           database support I need! What's going on here?
  1683.  
  1684.    6. Unix: I patched Apache with the FrontPage extensions patch, and
  1685.           suddenly PHP stopped working. Is PHP incompatible with the
  1686.           Apache FrontPage extensions?
  1687.  
  1688.    7. Unix/Windows: I have installed PHP, but when I try to access a PHP
  1689.           script file via my browser, I get a blank screen.
  1690.  
  1691.    8. Unix/Windows: I have installed PHP, but when try to access a PHP
  1692.           script file via my browser, I get a server 500 error.
  1693.  
  1694.    9. Some operating systems: I have installed PHP without errors, but
  1695.           when I try to start apache I get undefined symbol errors:
  1696.  
  1697. [mybox:user /src/php4] root# apachectl configtest
  1698.  apachectl: /usr/local/apache/bin/httpd Undefined symbols:
  1699.   _compress
  1700.   _uncompress
  1701.  
  1702.    10. Windows: I have installed PHP, but when I to access a PHP script
  1703.           file via my browser, I get the error:
  1704.  
  1705. cgi error:
  1706.  The specified CGI application misbehaved by not
  1707.  returning a complete set of HTTP headers.
  1708.  The headers it did return are:
  1709.  
  1710.    11. Windows: I've followed all the instructions, but still can't get
  1711.           PHP and IIS to work together!
  1712.  
  1713.    12. When running PHP as CGI with IIS, PWS, OmniHTTPD or Xitami, I get
  1714.           the following error: Security Alert! PHP CGI cannot be accessed
  1715.           directly..
  1716.  
  1717.    13. How do I know if my php.ini is being found and read? It seems like
  1718.           it isn't as my changes aren't being implemented.
  1719.  
  1720.    14. How do I add my PHP directory to the PATH on Windows?
  1721.    15. How do I make the php.ini file available to PHP on windows?
  1722.    16. Is it possible to use Apache content negotiation (MultiViews
  1723.           option) with PHP?
  1724.  
  1725.    17. Is PHP limited to process GET and POST request methods only?
  1726.  
  1727.    1. Why shouldn't I use Apache2 with a threaded MPM in a production
  1728.    environment?
  1729.  
  1730.    PHP is glue. It is the glue used to build cool web applications by
  1731.    sticking dozens of 3rd-party libraries together and making it all
  1732.    appear as one coherent entity through an intuitive and easy to learn
  1733.    language interface. The flexibility and power of PHP relies on the
  1734.    stability and robustness of the underlying platform. It needs a
  1735.    working OS, a working web server and working 3rd-party libraries to
  1736.    glue together. When any of these stop working PHP needs ways to
  1737.    identify the problems and fix them quickly. When you make the
  1738.    underlying framework more complex by not having completely separate
  1739.    execution threads, completely separate memory segments and a strong
  1740.    sandbox for each request to play in, feet of clay are introduced into
  1741.    PHP's system.
  1742.  
  1743.    If you feel you have to use a threaded MPM, look at a FastCGI
  1744.    configuration where PHP is running in its own memory space.
  1745.  
  1746.    And finally, this warning against using a threaded MPM is not as
  1747.    strong for Windows systems because most libraries on that platform
  1748.    tend to be threadsafe.
  1749.  
  1750.    2. Unix/Windows: Where should my php.ini file be located?
  1751.  
  1752.    By default on Unix it should be in /usr/local/lib which is
  1753.    <install-path>/lib. Most people will want to change this at
  1754.    compile-time with the --with-config-file-path flag. You would, for
  1755.    example, set it with something like:
  1756.    --with-config-file-path=/etc
  1757.  
  1758.    And then you would copy php.ini-dist from the distribution to
  1759.    /etc/php.ini and edit it to make any local changes you want.
  1760.    --with-config-file-scan-dir=PATH
  1761.  
  1762.    On Windows the default path for the php.ini file is the Windows
  1763.    directory. If you're using the Apache webserver, php.ini is first
  1764.    searched in the Apaches install directory, e.g. c:\program
  1765.    files\apache group\apache. This way you can have different php.ini
  1766.    files for different versions of Apache on the same machine.
  1767.  
  1768.    See also the chapter about the configuration file.
  1769.  
  1770.    3. Unix: I installed PHP, but every time I load a document, I get the
  1771.    message 'Document Contains No Data'! What's going on here?
  1772.  
  1773.    This probably means that PHP is having some sort of problem and is
  1774.    core-dumping. Look in your server error log to see if this is the
  1775.    case, and then try to reproduce the problem with a small test case. If
  1776.    you know how to use 'gdb', it is very helpful when you can provide a
  1777.    backtrace with your bug report to help the developers pinpoint the
  1778.    problem. If you are using PHP as an Apache module try something like:
  1779.  
  1780.      * Stop your httpd processes
  1781.      * gdb httpd
  1782.      * Stop your httpd processes
  1783.      * > run -X -f /path/to/httpd.conf
  1784.      * Then fetch the URL causing the problem with your browser
  1785.      * > run -X -f /path/to/httpd.conf
  1786.      * If you are getting a core dump, gdb should inform you of this now
  1787.      * type: bt
  1788.      * You should include your backtrace in your bug report. This should
  1789.        be submitted to http://bugs.php.net/
  1790.  
  1791.    If your script uses the regular expression functions (ereg() and
  1792.    friends), you should make sure that you compiled PHP and Apache with
  1793.    the same regular expression package. This should happen automatically
  1794.    with PHP and Apache 1.3.x
  1795.  
  1796.    4. Unix: I installed PHP using RPMS, but Apache isn't processing the
  1797.    PHP pages! What's going on here?
  1798.  
  1799.    Assuming you installed both Apache and PHP from RPM packages, you need
  1800.    to uncomment or add some or all of the following lines in your
  1801.    httpd.conf file:
  1802. # Extra Modules
  1803. AddModule mod_php.c
  1804. AddModule mod_php3.c
  1805. AddModule mod_perl.c
  1806.  
  1807. # Extra Modules
  1808. LoadModule php_module         modules/mod_php.so
  1809. LoadModule php3_module        modules/libphp3.so     # for PHP 3
  1810. LoadModule php4_module        modules/libphp4.so     # for PHP 4
  1811. LoadModule perl_module        modules/libperl.so
  1812.  
  1813.    And add:
  1814. AddType application/x-httpd-php3 .php3    # for PHP 3
  1815. AddType application/x-httpd-php .php      # for PHP 4
  1816.  
  1817.    ... to the global properties, or to the properties of the
  1818.    VirtualDomain you want to have PHP support added to.
  1819.  
  1820.    5. Unix: I installed PHP 3 using RPMS, but it doesn't compile with the
  1821.    database support I need! What's going on here?
  1822.  
  1823.    Due to the way PHP 3 built, it is not easy to build a complete
  1824.    flexible PHP RPM. This issue is addressed in PHP 4. For PHP 3, we
  1825.    currently suggest you use the mechanism described in the
  1826.    INSTALL.REDHAT file in the PHP distribution. If you insist on using an
  1827.    RPM version of PHP 3, read on...
  1828.  
  1829.    The RPM packagers are setting up the RPMS to install without database
  1830.    support to simplify installations and because RPMS use /usr/ instead
  1831.    of the standard /usr/local/ directory for files. You need to tell the
  1832.    RPM spec file which databases to support and the location of the
  1833.    top-level of your database server.
  1834.  
  1835.    This example will explain the process of adding support for the
  1836.    popular MySQL database server, using the mod installation for Apache.
  1837.  
  1838.    Of course all of this information can be adjusted for any database
  1839.    server that PHP supports. We will assume you installed MySQL and
  1840.    Apache completely with RPMS for this example as well.
  1841.  
  1842.      * First remove mod_php3 :
  1843.  
  1844. rpm -e mod_php3
  1845.  
  1846.      * Then get the source rpm and INSTALL it, NOT --rebuild
  1847.  
  1848. rpm -Uvh mod_php3-3.0.5-2.src.rpm
  1849.  
  1850.      * Then edit the /usr/src/redhat/SPECS/mod_php3.spec file
  1851.        In the %build section add the database support you want, and the
  1852.        path.
  1853.        For MySQL you would add --with-mysql=/usr The %build section will
  1854.        look something like this:
  1855.  
  1856. ./configure --prefix=/usr \
  1857. --with-apxs=/usr/sbin/apxs \
  1858. --with-config-file-path=/usr/lib \
  1859. --enable-debug=no \
  1860. --enable-safe-mode \
  1861. --with-exec-dir=/usr/bin \
  1862. --with-mysql=/usr \
  1863. --with-system-regex
  1864.  
  1865.      * Once this modification is made then build the binary rpm as
  1866.        follows:
  1867.  
  1868. rpm -bb /usr/src/redhat/SPECS/mod_php3.spec
  1869.  
  1870.      * Then install the rpm
  1871.  
  1872. rpm -ivh /usr/src/redhat/RPMS/i386/mod_php3-3.0.5-2.i386.rpm
  1873.  
  1874.    Make sure you restart Apache, and you now have PHP 3 with MySQL
  1875.    support using RPM's. Note that it is probably much easier to just
  1876.    build from the distribution tarball of PHP 3 and follow the
  1877.    instructions in INSTALL.REDHAT found in that distribution.
  1878.  
  1879.    6. Unix: I patched Apache with the FrontPage extensions patch, and
  1880.    suddenly PHP stopped working. Is PHP incompatible with the Apache
  1881.    FrontPage extensions?
  1882.  
  1883.    No, PHP works fine with the FrontPage extensions. The problem is that
  1884.    the FrontPage patch modifies several Apache structures, that PHP
  1885.    relies on. Recompiling PHP (using 'make clean ; make') after the FP
  1886.    patch is applied would solve the problem.
  1887.  
  1888.    7. Unix/Windows: I have installed PHP, but when I try to access a PHP
  1889.    script file via my browser, I get a blank screen.
  1890.  
  1891.    Do a 'view source' in the web browser and you will probably find that
  1892.    you can see the source code of your PHP script. This means that the
  1893.    web server did not send the script to PHP for interpretation.
  1894.    Something is wrong with the server configuration - double check the
  1895.    server configuration against the PHP installation instructions.
  1896.  
  1897.    8. Unix/Windows: I have installed PHP, but when try to access a PHP
  1898.    script file via my browser, I get a server 500 error.
  1899.  
  1900.    Something went wrong when the server tried to run PHP. To get to see a
  1901.    sensible error message, from the command line, change to the directory
  1902.    containing the PHP executable (php.exe on Windows) and run php -i. If
  1903.    PHP has any problems running, then a suitable error message will be
  1904.    displayed which will give you a clue as to what needs to be done next.
  1905.    If you get a screen full of HTML codes (the output of the phpinfo()
  1906.    function) then PHP is working, and your problem may be related to your
  1907.    server configuration which you should double check.
  1908.  
  1909.    9. Some operating systems: I have installed PHP without errors, but
  1910.    when I try to start apache I get undefined symbol errors:
  1911. [mybox:user /src/php4] root# apachectl configtest
  1912.  apachectl: /usr/local/apache/bin/httpd Undefined symbols:
  1913.   _compress
  1914.   _uncompress
  1915.  
  1916.    This has actually nothing to do with PHP, but with the MySQL client
  1917.    libraries. Some need --with-zlib, others do not. This is also covered
  1918.    in the MySQL FAQ.
  1919.  
  1920.    10. Windows: I have installed PHP, but when I to access a PHP script
  1921.    file via my browser, I get the error:
  1922. cgi error:
  1923.  The specified CGI application misbehaved by not
  1924.  returning a complete set of HTTP headers.
  1925.  The headers it did return are:
  1926.  
  1927.    This error message means that PHP failed to output anything at all. To
  1928.    get to see a sensible error message, from the command line, change to
  1929.    the directory containing the PHP executable (php.exe on Windows) and
  1930.    run php -i. If PHP has any problems running, then a suitable error
  1931.    message will be displayed which will give you a clue as to what needs
  1932.    to be done next. If you get a screen full of HTML codes (the output of
  1933.    the phpinfo() function) then PHP is working.
  1934.  
  1935.    Once PHP is working at the command line, try accessing the script via
  1936.    the browser again. If it still fails then it could be one of the
  1937.    following:
  1938.  
  1939.      * File permissions on your PHP script, php.exe, php4ts.dll, php.ini
  1940.        or any PHP extensions you are trying to load are such that the
  1941.        anonymous internet user ISUR_<machinename> cannot access them.
  1942.      * The script file does not exist (or possibly isn't where you think
  1943.        it is relative to your web root directory). Note that for IIS you
  1944.        can trap this error by ticking the 'check file exists' box when
  1945.        setting up the script mappings in the Internet Services Manager.
  1946.        If a script file does not exist then the server will return a 404
  1947.        error instead. There is also the additional benefit that IIS will
  1948.        do any authentication required for you based on the NTLanMan
  1949.        permissions on your script file.
  1950.  
  1951.    11. Windows: I've followed all the instructions, but still can't get
  1952.    PHP and IIS to work together!
  1953.  
  1954.    Make sure any user who needs to run a PHP script has the rights to run
  1955.    php.exe! IIS uses an anonymous user which is added at the time IIS is
  1956.    installed. This user needs rights to php.exe. Also, any authenticated
  1957.    user will also need rights to execute php.exe. And for IIS4 you need
  1958.    to tell it that PHP is a script engine. Also, you will want to read
  1959.    this faq.
  1960.  
  1961.    12. When running PHP as CGI with IIS, PWS, OmniHTTPD or Xitami, I get
  1962.    the following error: Security Alert! PHP CGI cannot be accessed
  1963.    directly..
  1964.  
  1965.    You must set the cgi.force_redirect directive to 0. It defaults to 1
  1966.    so be sure the directive isn't commented out (with a ;). Like all
  1967.    directives, this is set in php.ini
  1968.  
  1969.    Because the default is 1, it's critical that you're 100% sure that the
  1970.    correct php.ini file is being read. Read this faq for details.
  1971.  
  1972.    13. How do I know if my php.ini is being found and read? It seems like
  1973.    it isn't as my changes aren't being implemented.
  1974.  
  1975.    To be sure your php.ini is being read by PHP, make a call to phpinfo()
  1976.    and near the top will be a listing called Configuration File
  1977.    (php.ini). This will tell you where PHP is looking for php.ini and
  1978.    whether or not it's being read. If just a directory PATH exists than
  1979.    it's not being read and you should put your php.ini in that directory.
  1980.    If php.ini is included within the PATH than it is being read.
  1981.  
  1982.    If php.ini is being read and you're running PHP as a module, then be
  1983.    sure to restart your web server after making changes to php.ini
  1984.  
  1985.    14. How do I add my PHP directory to the PATH on Windows?
  1986.  
  1987.    On Windows NT, 2000, XP and 2003:
  1988.  
  1989.      * Go to Control Panel and open the System icon (Start -> Settings ->
  1990.        Control Panel -> System, or just Start -> Control Panel -> System
  1991.        for Windows XP/2003)
  1992.      * Go to the Advanced tab
  1993.      * Click on the 'Environment Variables' button
  1994.      * Look into the 'System Variables' pane
  1995.      * Find the Path entry (you may need to scroll to find it)
  1996.      * Double click on the Path entry
  1997.      * Enter your PHP directory ant the end, including ';' before (e.g.
  1998.        ;C:\php)
  1999.      * Press OK and restart your computer
  2000.  
  2001.    On Windows 98/Me you need to edit the autoexec.bat file:
  2002.  
  2003.      * Open the Notepad (Start -> Run and enter notepad)
  2004.      * Open the C:\autoexec.bat file
  2005.      * Locate the line with PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;..... and
  2006.        add: ;C:\php to the end of the line
  2007.      * Save the file and restart your computer
  2008.  
  2009.      Note: Be sure to reboot after following the steps above to ensure
  2010.      that the PATH changes are applied.
  2011.  
  2012.    The PHP manual used to promote the copying of files into the Windows
  2013.    system directory, this is because this directory (C:\Windows,
  2014.    C:\WINNT, etc.) is by default in the systems PATH. Copying files into
  2015.    the Windows system directory has long since been deprecated and may
  2016.    cause problems.
  2017.  
  2018.    15. How do I make the php.ini file available to PHP on windows?
  2019.  
  2020.    There are several ways of doing this. If you are using Apache, read
  2021.    their installation specific instructions (Apache 1, Apache 2),
  2022.    otherwise you must set the PHPRC environment variable:
  2023.  
  2024.    On Windows NT, 2000, XP and 2003:
  2025.  
  2026.      * Go to Control Panel and open the System icon (Start -> Settings ->
  2027.        Control Panel -> System, or just Start -> Control Panel -> System
  2028.        for Windows XP/2003)
  2029.      * Go to the Advanced tab
  2030.      * Click on the 'Environment Variables' button
  2031.      * Look into the 'System variables' pane
  2032.      * Click on 'New' and enter 'PHPRC' as the variable name and the
  2033.        directory where php.ini is located as the variable value (e.g.
  2034.        C:\php)
  2035.      * Press OK and restart your computer
  2036.  
  2037.    On Windows 98/Me you need to edit the autoexec.bat file:
  2038.  
  2039.      * Open the Notepad (Start -> Run and enter notepad)
  2040.      * Open the C:\autoexec.bat file
  2041.      * Add a new line to the end of the file: set PHPRC=C:\php (replace
  2042.        C:\php with the directory where php.ini is located). Please note
  2043.        that the path cannot contain spaces. For instance, if you have
  2044.        installed PHP in C:\Program Files\PHP, you would enter
  2045.        C:\PROGRA~1\PHP instead.
  2046.      * Save the file and restart your computer
  2047.  
  2048.    16. Is it possible to use Apache content negotiation (MultiViews
  2049.    option) with PHP?
  2050.  
  2051.    If links to PHP files include extension, everything works perfect.
  2052.    This FAQ is only for the case when links to PHP files don't include
  2053.    extension and you want to use content negotiation to choose PHP files
  2054.    from URL with no extension. In this case, replace the line AddType
  2055.    application/x-httpd-php .php with:
  2056. # PHP 4
  2057. AddHandler php-script php
  2058. AddType text/html php
  2059.  
  2060. # PHP 5
  2061. AddHandler php5-script php
  2062. AddType text/html php
  2063.  
  2064.    This solution doesn't work for Apache 1 as PHP module doesn't catch
  2065.    php-script.
  2066.  
  2067.    17. Is PHP limited to process GET and POST request methods only?
  2068.  
  2069.    No, it is possible to handle any request method, e.g. CONNECT. Proper
  2070.    response status can be sent with header(). If only GET and POST
  2071.    methods should be handled, it can be achieved with this Apache
  2072.    configuration:
  2073. <LimitExcept GET POST>
  2074. Deny from all
  2075. </LimitExcept>
  2076.